package cn.kgc.disk.aop;

import org.apache.log4j.Logger;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.ThrowsAdvice;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class AdviceAspect implements MethodBeforeAdvice,AfterReturningAdvice,ThrowsAdvice {
    private Logger logger=Logger.getLogger(AdviceAspect.class);
    @Override
    public void before(Method method, Object[] objects, Object o) throws Throwable {
        logger.debug("永远的前置增强");
    }

    @Override
    public void afterReturning(Object o, Method method, Object[] objects, Object o1) throws Throwable {
        logger.debug("返回值增强，"+o);
    }
    public void afterThrowing(Method method, Object[] args, Object target, Throwable ex){
        logger.debug("永远的异常增强，想改都改不掉 。发生错误的方法是"+method.getName()+",信息是"+ex.getMessage());
    }
}
